<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>政策增加</title>
<link rel="stylesheet" type="text/css"
	href="../../layui/css/layui.css" media="all">
<style type="text/css">
	body{
		margin:20px 0px;
	}
	iframe{
		border:0px solid;
		position:fixed;
		right:0px;
		top:0px;
		width:560px;
		height:400px;
	}
	
</style>
</head>
<body>
	<fieldset class="layui-elem-field layui-field-title"
		style="margin-top: 20px;">
		<legend>增加政策</legend>
	</fieldset>

	<form class="layui-form" action="../../policy/add" method="post">
		<div class="layui-form-item">
			<div class="layui-inline">
				<label class="layui-form-label">政策名称</label>
				<div class="layui-input-inline">
					<input type="text" name="policyName" id="policyName" required
						lay-verify="required" placeholder="政策名称" autocomplete="off" maxlength="10"
						class="layui-input">
				</div>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-inline">
				<label class="layui-form-label">政策内容</label>
				<div class="layui-input-inline">
					<input type="textarea" name="policyComment" id="policyComment" required
						lay-verify="required" placeholder="政策内容" maxlength="100"
						autocomplete="off" class="layui-input">
				</div>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-inline">
				<label class="layui-form-label">政策备注</label>
				<div class="layui-input-inline">
					<input type="text" name="policyRemark" id="policyRemark" required
						lay-verify="required" maxlength="100" placeholder="政策备注"
						autocomplete="off" class="layui-input">
				</div>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-inline">
				<label class="layui-form-label">可见公司</label>
				<div class="layui-input-block" id="filiale">
					
				</div>
			</div>
		</div>
		<input type="hidden" id="filIds" name="filIds">
		<div class="layui-form-item">
			<div class="layui-input-block">
				<input onclick="add()" type="submit" class="layui-btn" lay-submit=""
					lay-filter="Add" value="发布政策">
				<button type="reset" class="layui-btn layui-btn-primary">重置</button>
			</div>
		</div>
	</form>
	<div id="zc">
		<iframe src="../wsz/Policy.html"></iframe>
	</div>
	<script src="../../layui/layui.js"></script>
	<script src="../../res/js/jquery-1.10.2.js"></script>
	<script type="text/javascript">
		
		layui.use('form', function(){
			var form = layui.form
			,layer = layui.layer
			,$ = layui.$;
			
			var url = "../../filiale/findAllFiliale";
			$.ajax({
				url:url,
				data:null,
				success:function(data){
					for(var i=0;i<data.length;i++){
						$("#filiale").append("<i><input type='checkbox' name='fil' value="+data[i].filId+" title="+data[i].filName+" lay-skin='primary' lay-filter='filter'></i>");
						form.render();
					}
				},
				dataType:"JSON"
			});
			form.on('submit(Add)',function(){
				parent.location.reload(); // 父页面刷新
			});
		});
		function add(){
			var bb="";
			var temp="";
			var a=document.getElementsByName("fil");
			//alert(a.length);
			for(var i=0;i<a.length; i++){
				if(a[i].checked){
					temp=a[i].value;
					if(bb==""){
						bb=temp;
					}else{
						bb=bb+","+temp;
					}
				}
			}
			alert(bb);
			$("#filIds").val(bb);
		}
	</script>
</body>
</html>